<?php
	include "../public/commom/config.php";
	include "../public/commom/commom.php";
	
	$classCondition = isset($_GET["class_id"]) ? "WHERE class_id='" . $_GET["class_id"] . "'" : "";
?>

<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
		<title>更多</title>
		<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.1.0/css/bootstrap.min.css">
		<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU" crossorigin="anonymous">
		<link rel="stylesheet" type="text/css" href="public/css/index.css"/>
	</head>

	<body>
		<?php include "public/commom/header.php"; ?>
		<div id="more">
			<ul>
				<?php
					$sql = "SELECT news.*, class.name cname FROM news LEFT JOIN class ON (news.class_id = class.id) " . $classCondition;
					
					$result = mysqli_query($conn, $sql);
						
					while($row = mysqli_fetch_assoc($result)) {
						echo "<li>
								<b>[<a href='more.php?class_id=" . $row["class_id"] . "'>" . $row["cname"] . "</a>]</b>&nbsp;
								<a href='newsdetails.php?id=" . $row["id"] . "'>" . $row["title"] . "</a>
								<span class='right'>" . date("Y-m-d", $row["time"]) . "</span>
							</li>";
					}
					
					mysqli_close($conn);
					
				?>
			</ul>
		</div>
	</body>

</html>